package logic

import (
	"context"
	"tiktok/model/mysql"
	"tiktok/tiktokrpc/internal/svc"
	"tiktok/tiktokrpc/tiktokrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type AddTikTokLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewAddTikTokLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddTikTokLogic {
	return &AddTikTokLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *AddTikTokLogic) AddTikTok(in *tiktokrpc.AddTikTokRequest) (*tiktokrpc.AddTikTokResponse, error) {
	// todo: add your logic here and delete this line

	content := mysql.TikTokContent{
		Title:        in.Title,
		Url:          in.Url,
		TikTokUserId: in.UserId,
	}

	mysql.DB.Debug().Create(&content)

	return &tiktokrpc.AddTikTokResponse{Id: int64(content.ID)}, nil
}
